<template>
  <div>
    <!-- <Loading :loading="loading"> -->
    <NavBar>
      <template slot="content">
        <div>出单排行榜</div>
      </template>
    </NavBar>
    <div class="record-content">
      <img src="./img/bg.png" class="record-content-bg" />
      <img src="./img/top.png" class="record-content-top" />
      <img src="./img/bottom.png" class="record-content-bottom" />
      <div
        class="record-content-ranking flex-row flex-align-center flex-justify-center"
      >
        <div class="record-content-ranking-circle"></div>
        <div>实时显示出单保费排行</div>
      </div>
      <div class="record-content-list-out"></div>

      <div class="record-content-list-inner">
        <van-list
          v-model="loading"
          :finished="finished"
          finished-text="没有更多了"
          @load="onLoad"
        >
          <div
            class="record-content-list-item flex-row flex-align-center"
            v-for="(item, index) in recordList"
            :key="index"
            @click="handleGoto(item)"
          >
            <!-- <div class="record-content-list-item-img-out">
              
            </div> -->
            <img
              v-if="item.rank < 6"
              :src="imgUrl[index]"
              class="record-content-list-item-img"
            />
            <div v-else class="record-content-list-item-no">
              {{ index + 1 }}
            </div>
            <div class="record-content-list-item-label">{{ item.label }}</div>
          </div>
        </van-list>
      </div>
    </div>
    <!-- </Loading> -->
  </div>
</template>
<script>
import API from '@/services/h5/home'
import NavBar from '@/components/h5header'
// import Loading from '@/components/data-loading'
export default {
  components: { NavBar },
  data() {
    return {
      currentPage: 0,
      length: 10,
      recordList: [],
      finished: false,
      loading: false,
      imgUrl: [
        require('./img/one.png'),
        require('./img/two.png'),
        require('./img/three.png'),
        require('./img/four.png'),
        require('./img/five.png')
      ]
    }
  },
  created() {
    this.onLoad()
  },
  methods: {
    handleGoto(item) {
      this.$router.push({
        path: '/recordDetail',
        query: {
          previewOrderImg: item.previewOrderImg
        }
      })
    },
    async onLoad() {
      this.currentPage += 1
      this.loading = true
      this.finished = false
      let params = {
        length: this.length,
        curPage: this.currentPage
      }
      const res = await API.getTopDetail(params)
      let data = res.data
      let result = []
      if (data.code === 1000) {
        data.data.list.forEach(item => {
          let obj = {
            ...item,
            label: `恭喜${item.branchAbbrName}${item.memberName}成交一单${item.productAbbrName}${item.annualPrem}元${item.paymentPeriodDesc}交`
          }
          result.push(obj)
        })
        this.recordList = this.recordList.concat(result)
        if (this.recordList.length < data.data.count) {
          this.loading = false
        } else {
          this.loading = false
          this.finished = true
          return
        }
      }
      this.loading = false
    }
  }
}
</script>
<style scoped lang="less">
.record-content {
  position: relative;
  height: 740px;
  .record-content-bg {
    width: 375px;
    height: 725px;
    position: absolute;
    top: 0;
  }
  .record-content-top {
    width: 268px;
    height: 52px;
    position: absolute;
    top: 66.5px;
    left: 53.5px;
  }
  .record-content-bottom {
    width: 375px;
    height: 99px;
    position: absolute;
    bottom: 0;
    z-index: 1;
  }
  .record-content-ranking {
    width: 225px;
    margin: 0 75px;
    box-sizing: border-box;
    text-align: center;
    padding: 9.5px 17px 7.5px 17px;
    background-image: linear-gradient(#ffe79f, #fff6d7, #fff5d5, #ffe79f);
    box-shadow: @c-color-primary 0 5.5px 0 0;
    position: absolute;
    top: 150px;
    font-size: 17px;
    font-weight: bold;
    color: @c-color-primary;
    border-radius: 20px;
    z-index: 10;
    .record-content-ranking-circle {
      width: 5px;
      height: 5px;
      border-radius: 50%;
      background: @c-color-primary;
      margin-right: 5px;
    }
  }
  .record-content-list-out {
    width: 345px;
    height: 504.5px;
    background: #ffeb00;
    box-shadow: rgba(210, 1, 1, 0.14) 0 5.5px 9px 0;
    border-radius: 13px 13px 5px 5px;
    margin: 0 15px;
    position: absolute;
    top: 167.5px;
  }
  .record-content-list-inner {
    width: 345px;
    height: 504.5px;
    overflow-y: scroll;
    background: #fff;
    z-index: 2;
    box-shadow: rgba(210, 1, 1, 0.14) 0 5.5px 9px 0;
    border-radius: 13px 13px 0 0;
    margin: 0 15px;
    position: absolute;
    top: 171.5px;
    .record-content-list-item {
      margin-top: 30px;
      font-size: 12px;
      color: #333;
      &:last-child {
        margin-bottom: 30px;
      }
      &-img,
      &-no,
      &-label {
        margin-left: 18px;
      }
      &-img-out {
        width: 32px;
        height: 20px;
      }
      &-img {
        width: 19px;
        height: 19px;
        margin-left: 15px;
      }
      &-no {
        font-size: 16px;
        font-weight: bold;
        color: @c-color-primary;
        margin-top: 3px;
      }
      &-label {
        width: 253px;
        text-overflow: ellipsis;
        overflow: hidden;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
      }
    }
  }
}
</style>
